package com.wc.codeforces.离散化.Bouquet_Easy_Version;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.util.TreeSet;

/**
 * @Author congge
 * @Date 2024/7/24 16:30
 * @description https://codeforces.com/contest/1995/problem/B1
 */
public class Main {
    /**
     * 思路：
     * n种花, 个数需要计数
     * ai的范围有点大, 需要离线处理, 需要离散化
     * 具体步骤看代码吧
     */
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int N = 200010;
    // 离散化数组
    static int[] c = new int[N];
    // 离散化数组长度
    static int len = 0, n = 0;
    // 每一个数的个数, 原数组, 原数组长度
    static int[] num = new int[N], a = new int[N], ns = new int[N];
    static long m;
    static long[] ms = new long[N];

    public static void main(String[] args) {
        // 离线处理
        int T = sc.nextInt();
        for (int i = 1; i <= T; i++) {
            ns[i] = sc.nextInt();
            ms[i] = sc.nextLong();
            for (int j = 1; j <= ns[i]; j++) {
                a[++n] = sc.nextInt();
                c[n] = a[n];
            }
        }

        // 离散化
        Arrays.sort(c, 1, n + 1);
        for (int i = 1; i <= n; i++) {
            if (c[i] != c[i - 1]) c[++len] = c[i];
        }
        n = 0;

        // 做题
        for (int stp = 1; stp <= T; stp++) {
            long res = 0;
            m = ms[stp];
            TreeSet<Integer> set = new TreeSet<>();
            // 计数
            for (int j = 1; j <= ns[stp]; j++) {
                int idx = find(a[++n]);
                num[idx]++;
                set.add(idx);
            }

            // 每一个数
            for (int p : set) {
                int q = p + 1;
                // 全买 p
                long tot = m, ans = 0;
                if ((long) num[p] * c[p] <= tot) ans = (long) num[p] * c[p];
                else ans = tot / c[p] * c[p];

                tot -= ans;
                // 看下相邻的是否可以买
                if (c[q] == c[p] + 1) {
                    // 买了多少个p
                    int number = (int) (ans / c[p]);
                    int qnum = num[q];
                    // 剩下的先买q
                    if ((long) qnum * c[q] <= tot) {
                        ans += (long) qnum * c[q];
                        qnum = 0;
                    } else {
                        long cy = tot / c[q];
                        ans += cy * c[q];
                        tot -= cy * c[q];
                        qnum -= cy;
                    }
                    // 最多可以转换的数目
                    int mx = Math.min(number, qnum);
                    ans += Math.min(tot, mx);
                }
                res = Math.max(res, ans);
                num[p] = 0;
            }
            out.println(res);
        }
        out.flush();
    }

    // 找到该数字的下角标
    static int find(int x) {
        int l = 1, r = len;
        while (l < r) {
            int mid = l + r >> 1;
            if (c[mid] >= x) r = mid;
            else l = mid + 1;
        }
        return c[l] == x ? l : -1;
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}
